
#include "memory-tools.h"
//necessary
#include <stdlib.h>

#include "SyntaxNode.h"

void resetMemoryObservation(){
	__memory_allocated__=0;
}

//TODO testing
void* mallocMemory(int memoryToMalloc,const char* errorMessage){
	void* result=malloc(memoryToMalloc);
	if (result==NULL){
		fprintf(stderr,"%s",errorMessage);
		exit(EXIT_FAILURE);
		return NULL;
	}
	__memory_allocated__+=memoryToMalloc;
	return result;
}


void freeMemory(int memoryToFree,void* objectToFree){
	__memory_allocated__-=memoryToFree;
	free(objectToFree);
}


void testMemoryLeak(FILE* f){
	fprintf(f,"Memory allocated yet to be freed: %dB\n",__memory_allocated__);
}


int getMemoryAllocated(){
	return __memory_allocated__;
}


